The advent of Internet of Things (IoT) technology has led to the concept of the smart city, in which smart devices are recognized as a necessity. The applications installed on these devices generate large volumes of data that often require real-time processing. However, these devices have limited capabilities and are not capable of processing large amounts of data. Moving all this data to cloud data centers results in higher bandwidth usage, latency, cost and energy consumption. Therefore, providing services to delay-sensitive smart city applications in the cloud is a challenging issue, and meeting the requirements of these applications requires the use of a hybrid cloud and fog paradigm. Fog computing as a complement to the cloud allows data to be processed near smart devices. However, the resources in the fog layer are heterogeneous and have different capabilities, hence, appropriate scheduling of these resources is of great importance. In this paper, the problem of task scheduling for the smart city applications in the cloud-fog environment has been addressed. To this purpose, the task scheduling problem has been modeled as a multi-objective optimization problem, which aims to minimize service delay and energy consumption of the system under deadline constraint. Then, in order to solve this problem and achieve an appropriate scheduling strategy, non-dominated sorting genetic algorithm II (NSGA-II) with customized operators has been applied. In addition, in order to improve the diversity of the population and the convergence speed of the proposed algorithm, a combination of chaotic map and opposition-based learning methods have been used to generate the initial population. Also, the approach based on the penalty function has been employed to penalize the solutions that do not meet the deadline constraint. The simulation results reveal that the proposed scheduling algorithm, compared to its best competitor, improves service response delay, waiting time, execution delay and system energy consumption by 1. 49%, 1. 70%, 2. 7% and 1. 86%, respectively. Furthermore, by properly assigning tasks to the computing nodes, compared to the best competitor, the percentage of missed-deadline tasks is reduced by 1. 89%.